$(document).ready(function() {
	
	
			$('.confirm').click(function(event){
		event.preventDefault();
		$(".overlayHolder").fadeToggle("fast");

		var getID = $(this).attr('data-id');
		var name = $(this).attr('data-name');
		var confirmation = $(this).attr('data-con');
				
		overlayConfirm = '';
		overlayConfirm += '<div class="confirmationHolder">';
			overlayConfirm += '<div class="headerConfirm"><i class="icon-thumbs-up"></i> Confirmation <div class="loading"></div></div>';
			overlayConfirm += '<div class="confirmationContent">';
				overlayConfirm += 'Do you want to confirm <strong>' +name+'</strong>?';
			overlayConfirm += '</div>';
			overlayConfirm += '<div class="confirmBtnHolder">';
				overlayConfirm += '<div class="btn-group">';
					overlayConfirm += '<button class="btn btn-mini btn-info doconfirm" data-name="'+name+'" data-id="'+getID+'"><i class="icon-ok-sign"></i> Confirm</button>';
					overlayConfirm += '<button class="btn btn-mini btn-danger doCancel"><i class="icon-remove-sign"></i> Cancel</button>';
				
				overlayConfirm += '</div>';
			overlayConfirm += '</div>';
		overlayConfirm += '</div>';
		
		
		$('.boxOverlayContent').html(overlayConfirm);
		$('.doCancel').click(function(){
			$(".overlayHolder").hide();
		});
		$('.doconfirm').click(function(){
			var getItemID = $('.doconfirm').attr('data-id');
			var name = $('.doconfirm').attr('data-name');
				doConfirm(getItemID,name );
		});
	});
	
	$('.closeOverlay').click(function(){
		$(this).css({
			'display':'none'
		});	
	});
	
	$('.deny').click(function(event){
		event.preventDefault();
		$(".overlayHolder").fadeToggle("fast");

		var getID = $(this).attr('data-id');
		var name = $(this).attr('data-name');
		var confirmation = $(this).attr('data-con');
				
		overlayConfirm = '';
		overlayConfirm += '<div class="confirmationHolder">';
			overlayConfirm += '<div class="headerConfirm"><i class="icon-thumbs-up"></i> Confirmation</div>';
			overlayConfirm += '<div class="confirmationContent">';
				overlayConfirm += 'Do you want to deny <strong>' +name+'</strong>?';
			overlayConfirm += '</div>';
			overlayConfirm += '<div class="confirmBtnHolder">';
				overlayConfirm += '<div class="btn-group">';
					overlayConfirm += '<button class="btn btn-mini btn-info doconfirm" data-name="'+name+'"data-id="'+getID+'"><i class="icon-ok-sign"></i> Confirm</button>';
					overlayConfirm += '<button class="btn btn-mini btn-danger doCancel"><i class="icon-remove-sign"></i> Cancel</button>';
						
				overlayConfirm += '</div>';
			overlayConfirm += '</div>';
		overlayConfirm += '</div>';
		
		
		$('.boxOverlayContent').html(overlayConfirm);
		$('.doCancel').click(function(){
			$(".overlayHolder").hide();
		});
		$('.doconfirm').click(function(){
			var getItemID = $('.doconfirm').attr('data-id');
			var name = $('.doconfirm').attr('data-name');
				deny(getItemID,name);
		});
	});
	
	$('.closeOverlay').click(function(){
		$(this).css({
			'display':'none'
		});	
	});
});


function doConfirm(intRestoID,name){
			uri = 'dashboard/reservation_confirm';
			red ='dashboard/reserved_lists'
		        $.ajax({
        type: "POST",
        url: base_url+uri,
		data: {intRestoID:intRestoID},
        }).done(function(data) {
					ddd = '';
					ddd += '<div class="headerConfirm"><i class="icon-thumbs-up"></i> Success</div></br></br><b>';
					ddd += ' </b>Email Verification has been send to<b>  ' + name+'</b>';

		if(data>0)
			{
		$('.headerConfirm').html('Please wait....');
				setTimeout(function(){
					$('.boxOverlayContent').html(ddd);
						},2000);
				
						setTimeout(function(){
					$(location).attr('href', base_url+red);
					},4000);
			}
			else
			{
              $(location).attr('href', base_url+red);
			}
		
		});
		
		}
		function deny(intRestoID,name){
			uri = 'dashboard/reservation_deny';
			red ='dashboard/reserved_lists'
		        $.ajax({
        type: "POST",
        url: base_url+uri,
		data: {intRestoID:intRestoID},
        }).done(function(data) {
		ddd = '';
					ddd += '<div class="headerConfirm"><i class="icon-thumbs-up"></i> Success</div></br></br><b>';
					ddd += name+' </b>"Successfully Denied!"';
		if(data>0)
			{
		$('.headerConfirm').html('Please wait....');
				setTimeout(function(){
					$('.boxOverlayContent').html(ddd);
						},2000);
				
						setTimeout(function(){
					$(location).attr('href', base_url+red);
					},4000);
			}			
			else
			{
              $(location).attr('href', base_url+red);
			}
		
		});
		
		}
			$('.confirmed').click(function(event){
		event.preventDefault();
		$(".overlayHolder").fadeToggle("fast");
		var name = $(this).attr('data-name');	
		
		overlayConfirm = '';
		overlayConfirm += '<div class="confirmationHolder">';
			overlayConfirm += '<div class="headerConfirm"><i class="icon-thumbs-up"></i> Confirmation</div>';
			overlayConfirm += '<div class="confirmationContent">';
				overlayConfirm += '<strong>' +name+'</strong> is Already Confirmed';
			overlayConfirm += '</div>';
			overlayConfirm += '<div class="confirmBtnHolder">';
				overlayConfirm += '<div class="btn-group">';
					overlayConfirm += '<button class="btn btn-mini btn-info doCancel"><i class="icon-ok-sign"></i> OK</button>';
						
				overlayConfirm += '</div>';
			overlayConfirm += '</div>';
		overlayConfirm += '</div>';
		
		
		$('.boxOverlayContent').html(overlayConfirm);
		$('.doCancel').click(function(){
			$(".overlayHolder").hide();
		});
	});
	
	$('.closeOverlay').click(function(){
		$(this).css({
			'display':'none'
		});	
	});
		
		
		
		
		
		
		
		
		
		
		

